<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
	<script type="text/javascript">
		function go_seeimg(taskId) {
			window.open("<%=basePath %>seeimg?taskId=" + taskId);
		}
		function original_otherFuns(value, row, index) {
			var see_info = "", see_process = "", to_submit = "",to_delete="";
			var infoprams = row.processId + ',' + row.taskId + ',"'
					+ row.processName + '"';
			see_info = "<a onclick='look_info(" + infoprams
					+ ")' class='easyui-linkbutton button-teal handle-btn' >查看详情</a>";
			seeView = "<a onclick='go_seeimg("+row.taskId+")' class='easyui-linkbutton button-blue handle-btn'>流程图</a>";
			seeHandler = "<a onclick='see_all_handler("+row.taskId+")' class='easyui-linkbutton button-darkblue handle-btn'>办理人</a>";
			return see_info+seeView+seeHandler;
		}
		function look_info(processId, taskId, processName) {
			$("#see-my-info").window({
				onBeforeClose:function(){
					$("#see-my-info-layout-center").panel("clear");
				}
			})
			$("#see-my-info").window("open")
			//给窗口填充内容
			if (processName == "人员录用流程") {
				$("#see-my-info-layout-center").panel({href : 'to_employForm',
									onLoad : function() {
										if ($('.tabs-selected').text()=="已办流程") {
										$.post("findProcess", {
											processName : processName,
											processId : processId
										}, function(info) {
											info.employBirth = new Date(
													info.employBirth)
													.toLocaleDateString();
											info.employGraduatetime = new Date(
													info.employGraduatetime)
													.toLocaleDateString();
											info.employPosttime = new Date(
													info.employPosttime)
													.toLocaleDateString();
											$("#employForm").form("clear");
											$("#employForm").form("load", info);
										});
										
										//通过任务id去判断当前的批注填写方式，AJAX
										if (taskId != "") {
											$("#dept_boss").html(
															'<input name="deptBoss" id="dept_boss_comment"> ');
											$("#personnel").html(
															'<input name="personnel" id="personnel_comment">');
											$("#zong_boss").html(
															'<input name="zongBoss" id="zong_boss_comment">');
											$("#zong_boss_comment").textbox({
												readonly : true,
												width : '70%',
												height : '100px',
												labelAlign : 'right',
												labelWidth : '90px',
												label : '总经理签字：',
												multiline : true
											});
											$("#personnel_comment").textbox({
												readonly : true,
												width : '70%',
												height : '100px',
												labelAlign : 'right',
												labelWidth : '90px',
												label : '人事归档：',
												multiline : true
											})
											$("#dept_boss_comment").textbox({
												readonly : true,
												width : '70%',
												height : '100px',
												labelAlign : 'right',
												labelWidth : '90px',
												label : '部门主管签字：',
												multiline : true
											})
											//装载已经有的批注
											$.post("getAllComments", {
												taskId : taskId
											}, function(comments) {
												$("#comments_form").form(
														"load", comments);
											});
										} else {
											$("#comments_form").hide();
										}
									}
									}
								});
			}else if(processName=="人员借款流程"){
				$("#see-my-info-layout-center").panel({href : 'to_loanForm',
						onLoad : function() {
							$.post("findProcess", {
								processName : processName,
								processId : processId
							}, function(info) {
								info.loanUptime = new Date(info.loanUptime).toLocaleDateString();
								$("#loanForm").form("clear");
								$("#loanForm").form("load", info);
							});
							//通过任务id去判断当前的批注填写方式，AJAX
							if (taskId != "") {
								$('#loan_dept_boss_comment').textbox('readonly',true);
								$('#loan_zong_boss_comment').textbox('readonly',true);
								$('#loan_finance_comment').textbox('readonly',true);
								//装载已经有的批注
								$.post("getAllComments", {taskId:taskId},function(comments){
									$("#comments_form").form("load", comments);
								});
							}else {
								$("#comments_form").hide();
							}
						}
				});
			}else if(processName=="人员请假流程"){
							
			}else if(processName=="人员转正流程"){
				$("#see-my-info-layout-center").panel({href : 'to_standardForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							$("#standardForm").form("clear");
							$("#standardForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#standard_dept_boss_comment').textbox('readonly',true);
							$('#standard_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员调动流程"){
				
			}else if(processName=="人员还款流程"){
				
			}else if(processName=="人员加班流程"){
				$("#see-my-info-layout-center").panel({href : 'to_overworkForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							$("#overworkForm").form("clear");
							$("#overworkForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#overwork_dept_boss_comment').textbox('readonly',true);
							$('#overwork_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="人员离职流程"){
				$("#see-my-info-layout-center").panel({href : 'to_quitForm',
					onLoad : function() {
						$.post("findProcess", {
							processName : processName,
							processId : processId
						}, function(info) {
							info.quitUptime = new Date(info.quitUptime).toLocaleDateString();
							info.quitTime = new Date(info.quitTime).toLocaleDateString();
							switch (info.quitType) {
							case "retire":
								info.quitType = "退休";
								break;
							case "illness":
								info.quitType = "病退";
								break;
							case "dismiss":
								info.quitType = "辞退";
								break;
							case "resign":
								info.quitType = "辞职";
								break;
							}
							$("#quitForm").form("clear");
							$("#quitForm").form("load", info);
						});
						//通过任务id去判断当前的批注填写方式，AJAX
						if (taskId != "") {
							$('#quit_dept_boss_comment').textbox('readonly',true);
							$('#quit_zong_boss_comment').textbox('readonly',true);
							$('#quit_personnel_comment').textbox('readonly',true);
							//装载已经有的批注
							$.post("getAllComments", {taskId:taskId},function(comments){
								$("#comments_form").form("load", comments);
							});
						}else {
							$("#comments_form").hide();
						}
					}
				});
			}else if(processName=="通知发布流程"){
				
			}
		}

		$(function() {
			$("#originaldg").datagrid({
					onBeforeLoad : function(param) {
						param.processId = $("#processId").val();
						param.processType = $("#processType").val();
						param.name = $("#name").val();
					}
			});
			$("#original_query").linkbutton({
					onClick : function() {
						$('#original_search_from').form('submit',
							{
								onSubmit : function(param) {
									param.page = '1';
									param.rows = '10';
								},
								success : function(data) { //表单查询数据刷新DataGrid
									var resultData = $.parseJSON(data);
									$('#originaldg').datagrid('loadData',resultData);
								}
							});
					}
			});
		})
	</script>
	<div
		style="width: 99%; height: 99%; border: 1px solid white; background: white">
		<div style="margin: 10px; height: 8%">
			<form action="find_original_process" id="original_search_from" method="get">
				<input id="processId" name="processId" class="easyui-textbox"
					style="width: 20%;" label="流程编号：" labelAlign="right">
				<input id="name" name="name" class="easyui-textbox"
					style="width: 20%;" label="流程发起人：" labelAlign="right">
				<select id="processType" name="processType" class="easyui-combobox"
					style="width: 20%;" label="流程类别：" editable="false" labelAlign="right">
					<option value="">--请选择--</option>
					<option value="人员录用流程">录用申请单</option>
					<option value="人员转正流程">转正申请单</option>
					<option value="人员借款流程">借款申请单</option>
					<option value="人员请假流程">请假申请单</option>
					<option value="人员调动流程">调动申请单</option>
					<option value="人员还款流程">还款申请单</option>
					<option value="人员加班流程">加班申请单</option>
					<option value="人员离职流程">离职申请单</option>
					<option value="通知发布流程">通知申请单</option>
				</select>
				<a id="original_query" class="easyui-linkbutton button-line-blue"
					style="width: 10%; height: 30px; margin-left: 20px">检索</a>
			</form>
		</div>
		<!-- toolbar: '#tb' -->
		<table id="originaldg" style="width: 99%; height: 88%"
			data-options="
				url:'find_original_process',
				autoRowHeight:false,
				striped:true,
				pagination:true,
				rownumbers:true,
				singleSelect:true,
				remoteSort:false,
				pageSize:10,
				pageList:[10,15]
			">
			<thead>
				<tr>
					<th style="width: 10%" align="center"
						data-options="field:'processId',sortable:true">流程编号</th>
					<th style="width: 15%" align="center" data-options="field:'processName'">流程名称</th>
					<th style="width: 10%" align="center" data-options="field:'launchPeople'">流程发起人</th>
					<th style="width: 13%" align="center"
						data-options="field:'launchTime',sortable:true">流程发起时间</th>
					<th style="width: 16%" align="center"
						data-options="field:'taskName',sortable:true">当前任务</th>
					<th style="width: 13%" align="center"
						data-options="field:'startTime',sortable:true">任务开始时间</th>
					<th style="width: 24%" align="center"
						data-options="field:'other',formatter:original_otherFuns">操作</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
		
		
		<div id="see-my-info" class="easyui-window" title="流程表单"
			data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-form',closed:true"
			style="width: 60%; height: 90%; padding: 5px">
			<div id="see-my-info-layout" class="easyui-layout" data-options="fit:true">
				<div id="see-my-info-layout-center" data-options="region:'center'"
					align="center" style="padding: 10px;"></div>
				<div data-options="region:'south',border:false"
					style="text-align: right; padding: 5px 0 0;">
					<a class="easyui-linkbutton"
						data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)"
						onclick="$('#see-my-info').window('close');">取消</a>
				</div>
			</div>
		</div>
		<div id="win-all-handler" class="easyui-window" title="流程执行者"
			data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-form',closed:true"
			style="width: 50%; height: 70%; padding: 5px">
			<div id="win-all-handler-layout" class="easyui-layout" data-options="fit:true">
				<div id="win-all-handler-layout-center" data-options="region:'center'"
					align="center" style="padding: 10px;">
					<div id="win-all-handler-layout-center-dg"></div>	
				</div>
				<div data-options="region:'south',border:false"
					style="text-align: right; padding: 5px 0 0;">
					<a class="easyui-linkbutton"
						data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)"
						onclick="$('#win-all-handler').window('close');">取消</a>
				</div>
			</div>
		</div>
	</div>
</body>
</html>